//
//  LPTEarningHeadView.m
//  LPTClient
//
//  Created by mac on 2018/12/6.
//  Copyright © 2018年 zhaodd. All rights reserved.
//

#import "LPTEarningHeadView.h"

@interface LPTEarningHeadView ()

@property (nonatomic,strong)UILabel *balanceLabel;

@end

@implementation LPTEarningHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initSubViews];
    }
    return self;
}

-(void)initSubViews
{
    UIImageView *backGroundImage = [[UIImageView alloc] init];
    backGroundImage.image = [UIImage imageNamed:@"profit_bg_card"];
    backGroundImage.layer.cornerRadius = 4.0f;
    backGroundImage.clipsToBounds = YES;
    [self addSubview:backGroundImage];
    [backGroundImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.mas_equalTo(UIEdgeInsetsZero);
    }];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text = @"总资产（元）";
    titleLabel.font = [UIFont systemFontOfSize:14.0f];
    titleLabel.textColor = [UIColor whiteColor];
    [self addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.leading.mas_equalTo(22);
        make.top.mas_equalTo(25);
    }];
    
    UILabel *balanceLabel = [[UILabel alloc] init];
    balanceLabel.textColor = [UIColor whiteColor];
    balanceLabel.text = @"888.88";
    balanceLabel.font = [UIFont systemFontOfSize:20.0f];
    balanceLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:balanceLabel];
    self.balanceLabel = balanceLabel;
    [self.balanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.center.mas_equalTo(self);
    }];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [btn.titleLabel setFont:[UIFont systemFontOfSize:14.0f]];
    [btn setTintColor:[UIColor whiteColor]];
    [btn setTitle:@"提现>" forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor clearColor];
    btn.layer.cornerRadius = 37/2;
    btn.clipsToBounds = YES;
    [btn addTarget:self action:@selector(withdrawalAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(self);
        make.trailing.mas_equalTo(self).mas_offset(-12);
        make.size.mas_equalTo(CGSizeMake(70, 37));
    }];
}

//提现
-(void)withdrawalAction:(UIButton *)button
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(earningHeadViewDidClickWithdrawal)]) {
        [self.delegate earningHeadViewDidClickWithdrawal];
    }
}

-(void)refreshWithDic:(UserInfoModel *)model
{
    self.balanceLabel.text = [NSString stringWithFormat:@"+%@",model.doctor.account.balance];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
